// 提交 mutations是更改Vuex状态的唯一合法方法
// export const modifyAName = (state, name) => { // A组件点击更改餐馆名称为 A餐馆
//     state.resturantName = name // 把方法传递过来的参数，赋值给state中的resturantName
// }
// export const modifyBName = (state, name) => { // B组件点击更改餐馆名称为 B餐馆
//     state.resturantName = name
// }
import { WebSocketClient } from "../utils/websocket";

const initWebSock = (state, config) => {
  state.ws = new WebSocketClient(config);
  state.ws.init();
};

const setSid = (state, value) => {
  state.sid = value;
};
const setToken = (state, value) => {
  state.token = value;
  localStorage.setItem("usertoken", value);
};
//设置用户基本信息
const setUserInfo = (state, value) => {
  if (value === "") return;
  state.userInfo = value;
  localStorage.setItem("userInfo", JSON.stringify(value));
};
const setIslogin = (state, value) => {
  state.isLogin = value;
};
const setTid = (state, value) => {
  state.tid = value;
};
const setMessage = (state, value) => {
  state.num = value.message ? value.message : 0;
};
export {
  setSid,
  setUserInfo,
  setIslogin,
  setToken,
  setTid,
  initWebSock,
  setMessage,
};
